"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var BaseDao_1 = require('./BaseDao');
var ProjectsDao = (function (_super) {
    __extends(ProjectsDao, _super);
    function ProjectsDao() {
        _super.call(this);
        this.projectModel = this.dbManager.getModel("mProject");
    }
    ProjectsDao.prototype.add = function (project, callback) {
        var project_ = new this.projectModel(project);
        project_.save(callback);
    };
    ProjectsDao.prototype.get = function (projectId, callback) {
        this.projectModel.findOne({ _id: projectId }).exec(callback);
    };
    ProjectsDao.prototype.gets = function (callback) {
        this.projectModel.find().exec(callback);
    };
    ProjectsDao.prototype.getMines = function (userId, callback) {
        this.projectModel.find({ user: userId }).exec(callback);
    };
    ProjectsDao.prototype.update = function (project, callback) {
        var query = { _id: project._id };
        var updater = {
            title: project.title,
            description: project.description,
            open: project.open
        };
        this.projectModel.update(query, updater).exec(callback);
    };
    ProjectsDao.prototype.delete = function (projectId, callback) {
        this.projectModel.remove({ _id: projectId }).exec(callback);
    };
    return ProjectsDao;
}(BaseDao_1.BaseDao));
exports.ProjectsDao = ProjectsDao;
